package org.hagopa.games.moneypool.msgs.ContentTypes.game;

import java.nio.ByteBuffer;

import org.hagopa.games.moneypool.msgs.CommandsEnum;
import org.hagopa.games.moneypool.msgs.IMsgContent;

public class DiesThrow implements IMsgContent{
	private int marshalledSize = 16;
	private int acid = 0;
	private int first = 0;
	private int second = 0;
	public int getFirst() {
		return first;
	}

	public void setFirst(int first) {
		this.first = first;
	}

	public int getSecond() {
		return second;
	}

	public void setSecond(int second) {
		this.second = second;
	}

	
	public int getSize() {
		// TODO Auto-generated method stub
		return marshalledSize;
	}

	
	public byte[] marshallToByte() {
		ByteBuffer dataArray = ByteBuffer.allocate(64);
		
		byte [] bytes = new byte[64];
		dataArray.putInt(CommandsEnum.DIES_RESULT.idx());
		//dataArray.putInt(UpdateTypeEnum.DIES_UPDATE.idx());
		dataArray.putInt(this.acid);
		dataArray.putInt(this.first);
		dataArray.putInt(this.second);
		dataArray.rewind();
		this.marshalledSize = 16;
		dataArray.get(bytes,0,bytes.length);
		return bytes;
	}

	
	public boolean unmarshallFromByte(byte[] content) {
		ByteBuffer dataArray = ByteBuffer.wrap(content);
		if(null == dataArray)
		{
			return false;
		}
		dataArray.clear();
		//dataArray.rewind();
		dataArray.getInt();
		this.acid = dataArray.getInt();
		this.first = dataArray.getInt();
		this.second = dataArray.getInt();
		return true;
		
	}

	public int getAcid() {
		return acid;
	}

	public void setAcid(int acid) {
		this.acid = acid;
	}

        public String getConcatContent() {
            String outstr = null;
            outstr = String.valueOf(CommandsEnum.DIES_RESULT.idx()) + String.valueOf(this.acid)+ String.valueOf(this.acid)
                    + String.valueOf(this.first) + String.valueOf(this.second);
            return outstr;
        }

}
